package com.pioneer.gui.invoice.controller;

import java.util.Vector;
import java.util.HashMap;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import com.pioneer.gui.invoice.view.InvoiceNoPanel;
import com.pioneer.gui.invoice.view.NavigationPanel;
import com.pioneer.gui.invoice.util.InvoiceDAO;
import com.pioneer.gui.invoice.util.Constants;
import com.pioneer.gui.invoice.util.DropDownDataFactory;
import com.pioneer.gui.invoice.model.InvoiceModel;
import com.pioneer.gui.invoice.model.InvoiceTableModel;
import com.pioneer.gui.invoice.model.DropDownList;


import javax.swing.JFrame;

public class NewButtonAdapter
	implements ActionListener
	{
		private InvoiceModel model;
		private InvoiceDAO invoiceDAO;
		//private InvoiceNoPanel invoiceNoPanel;
		
		public NewButtonAdapter(InvoiceModel model)
		{
			this.model=model;
			//this.invoiceNoPanel=invoiceNoPanel;
			this.invoiceDAO=new InvoiceDAO();
		}
		
		public void actionPerformed(ActionEvent e)
		{
			/*this.model.setNew();
			//model.setSaveMode(InvoiceModel.NEW);
			//model.setInvoiceHeader(new InvoiceHeaderModel());
			//model.getInvoiceDetails().setTableData(new Vector());
			DropDownList allInvoiceNo=new DropDownList();
			invoiceNoPanel.invoiceNo.setModel(allInvoiceNo);
			String newNum=this.invoiceDAO.getNewInvoiceNo();
			allInvoiceNo.addItem(newNum);
			allInvoiceNo.setSelectedItem(newNum);
			invoiceNoPanel.invoiceNo.revalidate();
			invoiceNoPanel.invoiceNo.repaint();
			
			//if (NavigationPanel.this.panel.invoiceNoPanel.invoiceNo.getModel() instanceof DropDownList)
			//	allInvoiceNo=(DropDownList)NavigationPanel.this.panel.invoiceNoPanel.invoiceNo.getModel();
			//else
			//{
			//	allInvoiceNo=new DropDownList();
			//	NavigationPanel.this.panel.invoiceNoPanel.invoiceNo.setModel(allInvoiceNo);
			//}
			//String newNum=this.invoiceDAO.getNewInvoiceNo();
			//allInvoiceNo.addItem(newNum);
			//allInvoiceNo.setSelectedItem(newNum);
			//NavigationPanel.this.panel.invoiceNoPanel.invoiceNo.revalidate();
			//NavigationPanel.this.panel.invoiceNoPanel.invoiceNo.repaint();*/
		}
	}